//-------------------------------------------------------
// Copyright (c) 
// All rights reserved.
//
// File Name: IPCWndServer.h
// File Des: 窗口消息进程内/间通信 server 接口对象
// File Summary:
// Cur Version: 1.0
// Author:lzlong
// Create Data:2023-8-10
// History:
//         <Author>    <Time>        <Version>      <Des>
//      lzlong        2023-8-10     1.0
//-------------------------------------------------------
#pragma once
#include <string>
#include <wtypes.h>

class CWndForIPC;
class IIPCWndCallBack;
class CIPCWndServer
{
public:
    CIPCWndServer(void);
    ~CIPCWndServer(void);

    void set_server_name(const std::wstring& _strName);

    int set_handler(IIPCWndCallBack* _p_callback);

    void set_is_rec_same_server_name_msg(bool bRecSameSvrNameMs);

    HWND get_hwnd() const;

    int start_listen();

    int stop_listen();
private:
    CWndForIPC*        m_pWndIPC;
    
    IIPCWndCallBack* m_pCallBack;

    std::wstring    m_strServerName;

    bool            m_bRecSameSvrNameMsg; // 接收同窗口名称的消息 因为窗口可能被同名窗口覆盖
};

/*
// server:
CIPCWndServer is;
wstring m_strHostName = L"MsgWindowName";
is.set_server_name(m_strHostName);

is.set_handler(pcallback);
int iii = is.start_listen(); // 必须先设置回调  不然start_listen无效返回
::PostMessage(is.get_hwnd(), WM_USER + 0x65, 31, 52); // 也可以发送  进程内部可以调用
::SendMessage(is.get_hwnd(), WM_USER + 0x77, 15, 62);

// client:
 CIPCWndClient ic;
ic.set_connect_host_name(L"MsgWindowName");
//ic.set_host_server_hwnd(is.get_hwnd());
ic.post_message(898, 22, 33);
ic.send_message(899, 44, 55);
ic.send_msg_stringW(L"call you!");
*/


